home *** CD-ROM | disk | FTP | other *** search
-
- PROGRAM ShowEGA(input,output,picfile);
-
- { Copyright (c) 1987, Ciarcia's Circuit Cellar }
- { All Rights Reserved }
-
- { Version 1.01 May 12, 1987 }
- { Fixed SendEGA so it would work with more types }
- { of EGA boards. kwd }
-
- { shows image on EGA using direct color mappings }
-
- {$U- control-break checking during execution }
- {$C- control-break checking during I/O operations }
- {$R- array range checking }
-
- {$Ideclares.p declarations }
- {$Ihexutil.p hex utilities }
- {$Iserial.p serial interface code }
- {$Ipictures.p picture file code }
- {$Iimages.p image processing }
-
- CONST
- EGAint = $10; { EGA video services }
- graymax = 9; { # gray shades - 1 }
-
- TYPE
- crng = 0..graymax; { gray scale index }
- cmaptype = ARRAY[bitrng] OF crng;
-
- VAR
- r : regrec;
- cmap : cmaptype;
-
- {--- Assign EGA colors based on binary truncations }
-
- PROCEDURE ShadeEGA(pic1 : picptr;
- VAR cmap : cmaptype);
-
- VAR
- bin : bitrng; { index into bins }
- binsum : REAL; { accumulated # pels }
- binthresh : REAL;
- cnum : crng; { color numbers }
- histo : histtype; { intensity histogram }
-
- BEGIN
-
- Writeln('Assigning colors');
-
- FOR bin := 0 TO maxbit DO
- cmap[bin] := bin DIV 4;
-
- END;
-
-
- {--- Show picture on EGA }
-
- PROCEDURE SendEGA(pic : picptr;
- cmap : cmaptype);
-
- VAR
- r : regrec; { BIOS interface regs }
- row,col : INTEGER; { EGA coordinates }
- lndx : linerng; { line number }
- pndx : pelrng; { pel number }
- pelval1 : INTEGER; { pel value left }
- pelval2 : INTEGER; { pel value right }
-
- BEGIN
-
- r.AX := ($00 SHL 8) OR $10; { 640 x 350 / 16 colors }
- Intr(EGAint,r);
-
- row := 50;
- FOR lndx := 0 TO maxline DO BEGIN
- col := 64;
- FOR pndx := 0 TO maxpel DO BEGIN
- pelval1 := cmap[pic^.fmt.lines[lndx].pels[pndx]];
- r.AH := $0C;
- r.AL := pelval1;
- r.BX := $0000;
- r.CX := col;
- r.DX := row;
- Intr(EGAint,r);
- col := Succ(col);
- END;
- row := Succ(row);
- IF KeyPressed
- THEN BEGIN
- TextMode;
- HALT;
- END;
- END;
-
- END;
-
- {--- Main routine }
-
- BEGIN
-
- pic1 := NIL; { ensure new alloc }
- PicSetup(pic1); { set up picture array }
-
- filespec := GetFSpec(ParamStr(1));
-
- LoadPicture(filespec,pic1); { read picture }
-
- ShadeEGA(pic1,cmap); { determine color map }
-
- SendEGA(pic1,cmap); { send mapped picture }
-
- GoToXY(1,24);
- Write('Press Enter');
- Readln;
- TextMode;
-
- END.